package com.hnucm.springboot.springboot.service.impl;

import com.hnucm.springboot.springboot.dao.PersonMapper;
import com.hnucm.springboot.springboot.dao.StuCardMapper;
import com.hnucm.springboot.springboot.model.Person;
import com.hnucm.springboot.springboot.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {
    @Autowired
    PersonMapper personMapper;

    @Autowired
    StuCardMapper stuCardMapper;

    @Override
    public List<Person> getAllPerson() {
        return personMapper.getAllPerson();
    }
    @Override
    public int addPerson(Person person) {
        stuCardMapper.addStuCard(person.getStuCard());
        return personMapper.addPerson(person);
    }

    @Override
    public int deletePerson(int id,int stuid) {
        stuCardMapper.deleteStuCard(stuid);
        return personMapper.deletePerson(id);
    }

    @Override
    public int updatePerson(Person person) {
        stuCardMapper.updateStuCard(person.getStuCard());
        return personMapper.updatePerson(person);
    }


}
